'use strict';
(function () {
    angular.module('bki', [])
            .controller('mainController', function () {
                
            })
            .controller('ClientsController', function ($scope, $http) {

                this.listClients = function () {
                    $scope.clients = [];
                    $http.get('api/clients/list').success(function (data) {
                        $scope.clients = data.list;
                    });
                };
                this.addClient = function () {
                };
                this.init = function () {
                    //$scope.tab = 'clients';
                    this.listClients();
                };
                this.init();
            })
            .controller('BankController', function ($scope, $http) {

            })
            .config(['$httpProvider', function ($httpProvider) {
                    $httpProvider.interceptors.push(function ($q, $rootScope) {
                        $rootScope.alert = {
                            show: false,
                            msg: "",
                            hide: function () {
                                this.show = false;
                            }
                        };
                        return {
                            'responseError': function (rejection) {
                                $rootScope.alert.msg = rejection.data.message;
                                $rootScope.alert.show = true;
                                console.log(rejection);
                                return $q.reject(rejection);
                            }
                        };
                    });
                }]);
})();
